home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 52
/
Amiga Format AFCD52 (Issue 136, May 2000).iso
/
-in_the_mag-
/
workbench
/
scanning
/
scantrax
/
archiv
/
example.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
2000-03-05
|
8KB
|
319 lines
/*
<Example ARexx-Script V1.1 for ScanTraxV2.1>
<ScanTrax is © by Klaus Krause>
--------------------------------------------------------------------------------
Important change since ScanTrax V2.0:
Two ARexx commands are need now a special handling: SCAN & SAVE_PICTURE
Since 2.0 you will get back the control immediately after command call.
First: To get no problems you must insure that ScanTrax is not busy!
Use GET_REXX_STATUS to get the ScanTrax status condition.
Second: If you initialize a scan, you must know when the scan has finished.
Use GET_REXX_STATUS again, to get the ScanTrax status condition.
This command should be periodically called, until a 'READY' status was returned.
To waste no CPU time, you should use this command only about every 0.5 second.
This was realised with the DOS function 'Delay()' which is included
in the 'rexxsupport.library'.
After a 'GET_REXX_STATUS' call, you should call this Delay function.
The delay function will put your RexxTask into sleep mode until waiting time
has elapsed. While in sleep modetime, other tasks will have the full CPU power!
In this example a set of subfunctions are used, which will do ALL necassary
steps for you.
The following subfunctions are included in the subfunctionblock:
InitRexxSupport() -> Insert the library into the library-list
ScanPicture() -> Scan data into a tempfile
Savepicture() -> Convert data of tempfile into a real picture
WaitUntilReady() -> Wait until ScanTrax is ready for a new command
ScanTraxReady() -> Get logical status, returns '1' on a ready condition
To use these functions in your own project, simply add the subfunctionblock
at the end of this example to your ARexx-Script and watch this example how
to use these.
--------------------------------------------------------------------------------
*/
OPTIONS RESULTS
ADDRESS "SCANTRAX"
CALL InitRexxSupport() /*Insert Library into list {get access to Delay()} */
say "ScanTrax ARexx Demonstration:"
GET_REXX_VERSION
say " Rexx Version = " RESULT
say
say
/* "To insure that you have the only access to ScanTrax,"
"you must lock the User-Interface. Otherwise the user can"
"disturb your project..."
*/
DISPLAY_LOCK
say "A look at the current ARexx-picture-setup:"
GET_INTENSITY
say " Intensity = " RESULT "%"
GET_CONTRAST
say " Contrast = " RESULT "%"
GET_COLOR_RED
say " Color Red = " RESULT "%"
GET_COLOR_GREEN
say " Color Green = " RESULT "%"
GET_COLOR_BLUE
say " Color Blue = " RESULT "%"
GET_SHARPEN
say " Sharpen = " RESULT "%"
GET_GAMMA
say " Gamma = " RESULT
GET_JPEG_QUALITY
say " JPEG-Quality= " RESULT
say
say "------------------------------------------------------------"
say
say "Short example for setting the graphic mode:"
say
say "Adjusting the graphic-mode to BlackWhite Treshold."
SET_GFX_MODE BLACKWHITE
GET_GFX_MODE
say " ( This mode has the internal number: " RESULT ")"
say
say "Adjusting the graphic-mode to 8bit GreyScale."
SET_GFX_MODE GREYSCALE
GET_GFX_MODE
say " ( This mode has the internal number: " RESULT ")"
say
say "Adjusting the graphic-mode to number 2."
SET_GFX_MODE NUMBER 2
GET_GFX_MODE
say " ( Mode changes to internal number: " RESULT ")"
say
say "You want finally scan in 24bit color."
SET_GFX_MODE COLOR
GET_GFX_MODE
say " ( This mode has the internal number: " RESULT ")"
say
say "------------------------------------------------------------"
say
say "You enable filename-suffixes."
SET_SUFFIX_MODE 1
GET_SUFFIX_MODE
say " ( Current filename-suffix logical status is now: " RESULT ")"
say
say "Setting intensity to 0 %"
SET_INTENSITY '0'
say
say "Setting contrast to 14 %"
SET_CONTRAST '14'
say
say "Setting sharpness to 50 %"
SET_SHARPEN '50'
say
say "Setting gamma to 2.20"
SET_GAMMA '2.2'
say
GET_RESOLUTION XMIN
x_min = RESULT
GET_RESOLUTION XMAX
x_max = RESULT
say "Your horizontal resolution range is "x_min" to "x_max" dpi!"
GET_RESOLUTION YMIN
y_min = RESULT
GET_RESOLUTION YMAX
y_max = RESULT
say "Your vertical resolution range is "y_min" to "y_max" dpi!"
say
say "Setting scan resolution to 75 x 75 dpi."
SET_RESOLUTION 75 75
say
GET_SCALE XMIN
x_min = RESULT
GET_SCALE XMAX
x_max = RESULT
say "Your horizontal scaling range is "x_min" to "x_max" %!"
GET_SCALE YMIN
y_min = RESULT
GET_SCALE YMAX
y_max = RESULT
say "Your vertical scaling range is "y_min" to "y_max" %!"
say
say "Setting a 100 x 100 % Scale."
SET_SCALE 100 100
say
say
say "Setting centimeters as input unit for length values."
SET_MEASUREUNIT CM
say
GET_WINDOW XMAX
x_max = RESULT
GET_WINDOW YMAX
y_max = RESULT
say "Your maximal flatbed scanarea is "x_max" x "y_max" cm!"
say
say "Setting your ScanWindow to: 12.5 x 8 cm in Size, with an 5 x 5 cm Offset."
SET_WINDOW 5 5 12.5 8
SET_PROGRESSBAR_MODE 1 /*Enable a progress bar!*/
say "Now you are ready to start a scan, scanning into tempfile...."
success = ScanPicture()
IF success = 1
THEN say "Your scan was successful :-)"
ELSE DO /*Error: The script ends at this point*/
IF success = -1 THEN say "Last command was aborted :-("
IF success = 0 THEN say "An error has occured with last command :-("
DISPLAY_UNLOCK
CALL CloseRexxSupport()
EXIT 10
END
say
say "Saving some pictures from our tempfile file..."
say
say
say "|---PNG-EXAMPLE---------------------------------------------"
say "|Create an Icon for this and all following pictures:"
SET_ICON_MODE 1
GET_ICON_MODE
say "| ( Icon-Creation was set to logical number: " RESULT ")"
say "|Selecting a fast PNG compressionrate..."
SET_PNG_COMPRESSION 3
say "|Writing a PiNG picture to ram:Testpicture..."
success = SavePicture(PNG 'RAM:Testpicture')
say "|Logical result of write: " success
say
say "|---JPEG-EXAMPLE--------------------------------------------"
say "|Setting JPG Quality to 45"
SET_JPEG_QUALITY 45
say "|Writing a JPEG picture to ram:Testpicture..."
success = SavePicture(JPEG 'RAM:Testpicture')
say "|Logical result of write: " success
say
say "|---TARGA-EXAMPLE-------------------------------------------"
say "|Writing a TARGA picture to ram:Testpicture..."
success = SavePicture(TARGA 'RAM:Testpicture')
say "|Logical result of write: " success
say
say "|---DEEP-EXAMPLE--------------------------------------------"
say "|Writing a IFF-DEEP picture to ram:Testpicture..."
success = SavePicture(DEEP 'RAM:Testpicture')
say "|Logical result of write: " success
say
say "|---ILBM-EXAMPLE--------------------------------------------"
say "|Switching IFF-ILBM compression to ON"
SET_ILBM_COMPRESSION 1
say "|Writing a IFF-ILBM picture to ram:Testpicture..."
success = SavePicture(ILBM 'RAM:Testpicture')
say "|Logical result of write: " success
say
say "|---JPEG-EXAMPLE-(a-background-write)-----------------------"
SET_PROGRESSBAR_MODE 0
SET_ICON_MODE 0
say "|Setting JPG Quality to 5"
SET_JPEG_QUALITY 5
say "|Writing a JPEG picture to ram:Testpicture..."
success = SavePicture(JPEG 'RAM:TestpictureSecret')
say "|Logical result of write: " success
say
/*---SHUT-DOWN---*/
DISPLAY_UNLOCK /*UnLock the User-Interface*/
say "-EXAMPLE-RESULTS-------------------------------------------"
say "Looking into the RamDisk for your pictures:"
ADDRESS COMMAND "C:list ram:Testpicture#?"
say
say "ARexx example has finished. Thanks for watching this :-)"
EXIT 0 /* END OF EXAMPLE SCRIPT */
/*-------------------SUB-FUNCTION-BLOCK---------------------*/
InitRexxSupport:
IF ~SHOW('L', "rexxsupport.library") THEN
IF ~ADDLIB('rexxsupport.library', 0, -30,0) THEN EXIT 10
return 1
/* END of InitRexxSupport() */
WaitUntilReady:
DO FOREVER
GET_STATUS
IF RC ~= 0 THEN return 0
IF RESULT = 'READY' THEN return 1
call delay(25)
END
/* END of WaitUntilReady() */
ScanTraxReady:
GET_STATUS
IF RC ~= 0 THEN return 0
IF RESULT = 'READY' THEN return 1
IF RESULT = 'ABORT' THEN return 1
return 0
/* END of ScanTraxReady() */
ScanPicture:
CALL WaitUntilReady()
SCAN
IF RC ~= 0 THEN return 0
DO FOREVER
call delay(25)
GET_STATUS
IF RC ~= 0 THEN return 0
IF RESULT = 'READY' THEN return 1
IF RESULT = 'ABORT' THEN return -1
END
/* END of ScanPicture() */
SavePicture:
parse arg keyword1 name1
CALL WaitUntilReady()
SAVE_PICTURE strip(keyword1) strip(name1)
IF RC ~= 0 THEN return 0
DO FOREVER
call delay(25)
GET_STATUS
IF RC ~= 0 THEN return 0
IF RESULT = 'READY' THEN return 1
IF RESULT = 'ABORT' THEN return -1
END
/* END of ScanPicture() */
/*--END-OF-----------SUB-FUNCTION-BLOCK---------------------*/